<?php echo form_open('/' . $this->curl . '/permissions/'. $id_role, 'id="myform" name="myform"')?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" id="grid" class="display">
<thead>
<tr>
	<th><?php echo T_('Доступ'); ?></th>
	<?php $num_roles = count($roles);  ?>
	<?php foreach ($roles as $role): ?>
		<th><?php echo $role ?></th>
	<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php $last_category = ''; ?>
<?php foreach ($resources as $resource): ?>
	<?php if ($resource->category != $last_category): ?>
		<tr>
			<td><strong><?php echo $resource->category ?></strong></td>
			<?php foreach ($roles as $id_role => $role): ?>
				<td class="t-center"></td>
			<?php endforeach; ?>		
		</tr>
		<tr id="tr_<?php echo $resource->id?>">
			<td>&nbsp;&nbsp;<?php echo $resource->description?></td>
			<?php foreach ($roles as $id_role => $role): ?>
				<?php $checked = (!empty($permissions[$resource->id][$id_role])) ? TRUE : FALSE; ?>
				<td class="t-center"><?php echo form_checkbox('rid[]', $resource->id.'_'.$id_role, $checked, 'id="rb'. $id_role.'"')?></td>
			<?php endforeach; ?>
		</tr>
		<?php $last_category = $resource->category ?>
	<?php else: ?>
		<tr id="tr_<?php echo $resource->id?>">
			<td>&nbsp;&nbsp;<?php echo $resource->description?></td>
			<?php foreach ($roles as $id_role => $role): ?>
				<?php $checked = (!empty($permissions[$resource->id][$id_role])) ? TRUE : FALSE; ?>
				<td class="t-center"><?php echo form_checkbox('rid[]', $resource->id.'_'.$id_role, $checked, 'id="rb'. $id_role.'"')?></td>
			<?php endforeach; ?>
		</tr>
	<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>

<input name="edit" type="submit" class="input-submit" id="submit" value="<?php echo T_('Сохранить')?>" />
	
<?php echo form_close()?>

<script type="text/javascript">
var oTable;

$(document).ready(function() {										
	/* Init DataTables */
	oTable = $('#grid').dataTable(
	{
		"oLanguage": {
		"sLengthMenu": "Показывать _MENU_ записей на стр.",
		"sZeroRecords": "Нет данных.",
		"sInfo": "От _START_ до _END_ из _TOTAL_ записей",
		"sInfoEmpty": "0 записей",
		"sInfoFiltered": "(filtered from _MAX_ total records)",
		"sSearch": "Искать",
		"oPaginate": {
			"sFirst": "Первая",
			"sLast": "Последняя",
			"sNext": "Вперед",
			"sPrevious": "Back"
			}
		},
		"aaSorting": [],
		"aoColumns": [
  			{ "bSortable": false }
  			<?php foreach ($roles as $role): ?>
  			,{ "bSortable": false }
  			<?php endforeach; ?>
		],		
														
		"bPaginate": false,
		"bLengthChange": true,
		"bFilter": true,	
		"bSort": true,
		"bInfo": true,
		"bAutoWidth": true,
		"bJQueryUI": true,
		"sPaginationType": "full_numbers"	
	});
});	
</script>